// part1:C09:ex9.47.cpp
// find char from a string.
#include <iostream>
#include <string.h>
using namespace std;

void find_char(string& str, const string& chars) {
  string::size_type pos = 0;
  cout << "from " << str << " find " << chars << endl;
  while ((pos = str.find_first_of(chars, pos)) != string::npos) {
    cout << "pos: " << pos << ", char: " << str[pos] << endl; 
    pos++;
  }
}

int main(void) {
  string s1 = "ab2c3d7R4E6";
  find_char(s1, "0123456789");
  cout << endl << "find all alpha!" << endl;
  string chars = "abcdefghijklmnopqrstuvwxyz" \
    "ABCDEFGHIGKLMNOPQRSTUVWXYZ";
  find_char(s1, chars);

  return 0;
}
